﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace VisualWix
{
    /// <summary>
    /// Interaction logic for ShortcutWindow.xaml
    /// </summary>
    public partial class ShortcutWindow : Window
    {
        ShortcutItem shortcutInfo = null;

        public ShortcutItem ShortcutInfo
        {
            get { return shortcutInfo; }            
        }

        FileItem selectedFile = null;

        DirectoryItem targetDirectoryInfo = null;

        public DirectoryItem TargetDirectoryInfo
        {
            get { return targetDirectoryInfo; }
            set { targetDirectoryInfo = value; }
        }

        public ShortcutWindow()
        {
            InitializeComponent();
        }

        private void ButtonOk_Click(object sender, RoutedEventArgs e)
        {
            shortcutInfo = new ShortcutItem();
            shortcutInfo.Name = TextBoxName.Text;
            shortcutInfo.Description = TextBoxDescription.Text;
            shortcutInfo.Source = selectedFile.GetTargetPath();
            shortcutInfo.TargetFile = selectedFile.Name;
            shortcutInfo.TargetDirectory = selectedFile.ParentItem.ID;

            this.Close();
        }

        private void ButtonCancel_Click(object sender, RoutedEventArgs e)
        {
            shortcutInfo = null;
            this.Close();
        }

        private void ButtonBrowse_Click(object sender, RoutedEventArgs e)
        {
            TargetFileWindow fileSelectionwindow = new TargetFileWindow();
            fileSelectionwindow.TargetDirectoryInfo = targetDirectoryInfo;
            fileSelectionwindow.ShowDialog();

            if (fileSelectionwindow.SelectedFile != null)
            {
                selectedFile = fileSelectionwindow.SelectedFile;
                TextBoxTarget.Text = selectedFile.Name;
            }
            
        }


    }
}
